<template>
  <div>
    <el-dialog
      title="确认"
      :close-on-click-modal="false"
      :visible.sync="visible"
      width="400px">
      <el-form
        ref="dataForm"
        :model="dataForm"
        label-position="top"
        label-width="100px">
        <el-form-item label="审核备注" prop="remark">
          <el-input
            type="textarea"
            :rows="4"
            placeholder="审核备注"
            maxlength="60"
            v-model="dataForm.remark"></el-input>
          <div style="text-align: right;">{{count}} / 60</div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="submitForm()">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  // api
  import { audit } from '@/api/costSubsidies'

  export default {
    name: 'cost-audit',
    data() {
      return {
        visible: false,
        dataForm: {
          portId: '',
          auditStatus: null,
          remark: ''
        }
      }
    },
    computed: {
      count() {
        return this.dataForm.remark.length
      }
    },
    methods: {
      init(portId, auditStatus) {
        this.dataForm.portId = portId.portId
        this.dataForm.auditStatus = auditStatus
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
        })
      },
      submitForm() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            audit(this.dataForm).then((res) => {
              this.$message({
                message: '操作成功',
                type: 'success'
              })
              this.visible = false
              this.$emit('refresh')
            })
          } else {
            return false
          }
        })
      },
      close() {
        this.visible = false
        this.$refs['dataForm'].resetFields()
      }
    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" rel="stylesheet/scss" type="text/scss">

</style>
